package com.cssw.fyzb.core.dao.acct;

import com.cssw.fyzb.core.model.dodb.RnbExchangeCoinLog;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @Author: yangyiqun
 * @Date: 2021/1/29 17:33
 */
@Repository
public class RnbExchangeCoinLogDaoImpl implements RnbExchangeCoinLogDao {

    @Override
    public void save(Long userId, BigDecimal rnb, String acctType, BigDecimal coin, String tradeNo,
                                       String status, String remark) {
        RnbExchangeCoinLog log = new RnbExchangeCoinLog();
        log.setUserId(userId);
        log.setRnb(rnb);
        log.setAcctType(acctType);
        log.setCoin(coin);
        log.setTradeNo(tradeNo);
        log.setStatus(status);
        log.setRemark(remark);
        log.setCreateTime(new Date());
        log.save();
    }

    @Override
    public RnbExchangeCoinLog getByTradeNo(String tradeNo) {
        String sql = "select * from t_rnb_exchange_coin_log where trade_no = ?";
        return RnbExchangeCoinLog.dao.findFirst(sql, tradeNo);
    }

    @Override
    public void updateStatus(Long logId, String status, String remark) {
        RnbExchangeCoinLog log = new RnbExchangeCoinLog();
        log.setLogId(logId);
        log.setRemark(remark);
        log.setStatus(status);
        log.setComplateTime(new Date());
        log.update();
    }
}
